package com.docs.core.io;

import cn.hutool.core.io.FileUtil;
import cn.hutool.core.io.IoUtil;

import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;

/**
 * https://hutool.cn/docs/#/core/IO/IO%E5%B7%A5%E5%85%B7%E7%B1%BB-IoUtil
 */
public class IoUtils {

    private String path = "C:/Users/LENOVO/Desktop/上传文件/io/测试图片.jpg";

    public static void main(String[] args) {
        IoUtils ioUtils = new IoUtils();
        ioUtils.copy();
    }

    /**
     * copy
     * 从输入流读取，从输出流写出
     */
    public void copy(){
        BufferedInputStream inputStream = FileUtil.getInputStream(path);
        BufferedOutputStream outputStream = FileUtil.getOutputStream("C:/Users/LENOVO/Desktop/上传文件/io/copy.jpg");

        long copy = IoUtil.copy(inputStream, outputStream);

        System.out.println(copy);
    }
}
